// miniprogram/pages/personal/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    name_status:"请先登录",
    headImg:"../../images/head.png",
    username:""  
  },

  onShow: function () {
    this.bindGetUserInfo();
  },
  bindGetUserInfo (e) {
    let that=this;
    wx.showLoading({
      title: '加载中...',
    })
    app.getUserToken(function (err, token) {
      wx.request({
        url: app.globalData.url +'/index.php?s=api/index/detail',
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        method: 'POST',
        data: {token:app.globalData.token,app_id:10001},
        success: (res) => {
          wx.hideLoading();
          if(res.data.code == 1){
            that.setData({
              headImg: res.data.data.userInfo.avatarUrl,
              username:res.data.data.userInfo.nickName
            })
          }
        }
      })
    })


  },

  goMyorder:function(){
    wx.navigateTo({
      url: '../orders/orders'
    })
  },

  login:function(){
    wx.navigateTo({
      url: '../login/login'
    })
  },

  goMycheck:function(){
    wx.navigateTo({
      url: '../myCheck/index'
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})